package com.foodconflict.action;

import com.foodconflict.domain.Conflict;
import com.foodconflict.service.ConflictService;
import com.foodconflict.util.ActionBase;
import com.foodconflict.util.StringConvertor;

public class ConflictModelAction extends ActionBase  {
	private ConflictService conflictService;
	private String food1ID;
	private String food2ID;
	private Conflict conflict;
	
	public ConflictService getConflictService() {
		return conflictService;
	}
	public void setConflictService(ConflictService conflictService) {
		this.conflictService = conflictService;
	}

	
	public String getFood1ID() {
		return food1ID;
	}
	public void setFood1ID(String food1ID) {
		this.food1ID = food1ID;
	}
	public String getFood2ID() {
		return food2ID;
	}
	public void setFood2ID(String food2ID) {
		this.food2ID = food2ID;
	}

	public Conflict getConflict() {
		return conflict;
	}
	public void setConflict(Conflict conflict) {
		this.conflict = conflict;
	}
	public String insertNew()
	{
		if(this.conflict != null)
		{
			conflictService.insertNew(conflict, new StringConvertor(food1ID).toInt(0), new StringConvertor(food2ID).toInt(0));
			return success("listAll");
		}else{
			return "input";
		}
	}
	
	public String update()
	{
		conflictService.update(conflict);
		return success("update");
	}
	
	public String delete()
	{
		conflictService.delete(conflict.getCid());
		return success("delete");
	}
	
	public String showMe()
	{
		conflict = conflictService.findConflict(conflict.getCid());
		return success("showMe");
	}
}
